package com.jie.web.controller;


import com.jie.service.UserAdminService;
import com.jie.vo.CommonResponse;
import com.jie.vo.UserLoginVo;
import com.jie.vo.UserRegisteredVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xiaojie
 * @since 2023-11-01
 */
@RestController
@RequestMapping("/user-admin")
@Api(tags = "用户管理模块")
public class UserAdminController {
    @Autowired
    private UserAdminService adminService;

    /**
     * 用户登录接口
     * @param userLoginVo
     * @param request
     * @return
     */
    @ApiOperation(value = "登录接口")
    @PostMapping("/login")
    public CommonResponse login(@RequestBody UserLoginVo userLoginVo, HttpServletRequest request){
        return adminService.login(userLoginVo.getNickname(),
                userLoginVo.getPassword(),
                userLoginVo.getCode(),
                request);
    }

    /**
     * 用户注册接口
     * @param userRegisteredVO
     * @param request
     * @return
     */
    @ApiOperation(value = "注册")
    @PostMapping("/registered")
    public CommonResponse registeredUserAuth(@RequestBody UserRegisteredVO userRegisteredVO, HttpServletRequest request){
        return adminService.registeredUserAuth(userRegisteredVO,request);
    }
}

